//
//  GYMainShopCell.m
//  GoodLuck
//
//  Created by apple on 2018/2/5.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import "GYMainShopCell.h"

static NSString *mainShopCellIdentifier = @"mainShopCellIdentifier";

@interface GYMainShopCell ()

@property (weak, nonatomic) IBOutlet UILabel *storeNameLable;
@property (weak, nonatomic) IBOutlet UILabel *storeDesLable;
@property (weak, nonatomic) IBOutlet UILabel *storeServiceLable;
@property (weak, nonatomic) IBOutlet UILabel *storeliveLable;


@end

@implementation GYMainShopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

+ (instancetype)mainShopCellWithTableView:(UITableView *)tableView {
    GYMainShopCell *cell = [tableView dequeueReusableCellWithIdentifier:mainShopCellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass([GYMainShopCell class]) owner:nil options:nil] firstObject];
    }
    return cell;
}

- (void)setGoodsDetails:(NSDictionary *)goodsDetails {
    _goodsDetails = goodsDetails;
    
    NSDictionary *store_info = [goodsDetails objectForKey:@"store_info"];
    self.storeNameLable.text = [store_info objectForKey:@"store_name"];
    NSDictionary *store_credit = [store_info objectForKey:@"store_credit"];
    
    NSDictionary*store_desccredit = [store_credit objectForKey:@"store_desccredit"];
    self.storeDesLable.text = [NSString stringWithFormat:@"%@: %0.1f",[store_desccredit objectForKey:@"text"],[[store_desccredit objectForKey:@"credit"] floatValue]];
    
    NSDictionary *store_servicecredit = [store_credit objectForKey:@"store_servicecredit"];
    self.storeServiceLable.text = [NSString stringWithFormat:@"%@: %0.1f",[store_servicecredit objectForKey:@"text"],[[store_servicecredit objectForKey:@"credit"] floatValue]];
    
    NSDictionary *store_deliverycredit = [store_credit objectForKey:@"store_deliverycredit"];
    self.storeliveLable.text = [NSString stringWithFormat:@"%@: %0.1f",[store_deliverycredit objectForKey:@"text"],[[store_deliverycredit objectForKey:@"credit"] floatValue]];
}


- (CGFloat)cellHeight:(NSDictionary *)model {
    self.goodsDetails = model;
    
    [self layoutIfNeeded];
    
    return CGRectGetMaxY(self.storeServiceLable.frame) + 15;
}
@end
